<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			
			<ul>
				<li v-for="item in msglist">{{item}}</li>
			</ul>
			<div id="footer">
				<my-component :number="num" @chil="mychil"></my-component>
			</div>
			
		</div>
		
		<template id="item">
			<div>
				<input type="text" v-model="msg" placeholder="信息" />
				<button type="button" @click="test">发送emit</button>
			</div>
		</template>
		
		<script type="text/javascript">
			Vue.component("myComponent",{
				template:"#item",
				data() {
					return {
						msg:''
					}
				},
				methods:{
					test(){
						this.$emit('chil',this.msg)
						this.msg = ''
					}
				}
			})
			var vm = new Vue({
				el:'#app',
				data() {
					return {
						num: 2000,
						msglist:['你好']
					}
				},
				methods:{
					mychil(val){
						console.log(val);
						this.msglist.push(val)
					}
				}
			})
		</script>
		<style type="text/css">
			#footer{
				position: fixed;
				bottom: 0;
			}
		</style>
	</body>
</html>
